'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;

  router.get('/', controller.admin.home.index);
  router.get('/admin', controller.admin.home.index);
  router.get("/admin/manager/edit/:id", controller.admin.manager.edit);
  router.post("/admin/manager/:id", controller.admin.manager.update);
  router.get('/admin/manager/delete/:id', controller.admin.manager.delete);
  router.get('/admin/manager/create', controller.admin.manager.create);
  router.get('/admin/manager', controller.admin.manager.index);
  router.post('/admin/manager', controller.admin.manager.save);

  // 用户登录
  router.get('/admin/login', controller.admin.home.login);
  router.post('/admin/loginevent', controller.admin.home.loginevent);
  router.get('/admin/logout', controller.admin.home.logout);

  router.get('/admin/user/delete/:id', controller.admin.user.delete);
  router.get('/admin/user/edit/:id', controller.admin.user.edit);
  router.get('/admin/user', controller.admin.user.index);
  router.get('/admin/user/create', controller.admin.user.create);
  router.post('/admin/user', controller.admin.user.save);
  router.post('/admin/user/:id', controller.admin.user.update);

  
  // 年级
  router.get('/admin/class/delete/:id', controller.admin.class.delete);
  router.get('/admin/class/edit/:id', controller.admin.class.edit);
  router.get('/admin/class/create', controller.admin.class.create);
  router.post('/admin/class', controller.admin.class.save);
  router.get('/admin/class', controller.admin.class.index);
  router.post('/admin/class/:id', controller.admin.class.update);

  // 学科
  router.get('/admin/branch/delete/:id', controller.admin.branch.delete);
  router.get('/admin/branch/edit/:id', controller.admin.branch.edit);
  router.get('/admin/branch/create', controller.admin.branch.create);
  router.post('/admin/branch', controller.admin.branch.save);
  router.get('/admin/branch', controller.admin.branch.index);
  router.post('/admin/branch/:id', controller.admin.branch.update);

  // 成绩
  router.get('/admin/score/delete/:id', controller.admin.score.delete);
  router.get('/admin/score/edit/:id', controller.admin.score.edit);
  router.get('/admin/score/create/:id', controller.admin.score.create);
  router.post('/admin/score', controller.admin.score.save);
  router.get('/admin/score', controller.admin.score.index);
  router.post('/admin/score/:id', controller.admin.score.update);

  // 文章管理
  router.get('/admin/article/delete/:id', controller.admin.article.delete);
  router.get('/admin/article/edit/:id', controller.admin.article.edit);
  router.get('/admin/article', controller.admin.article.index);
  router.get('/admin/article/create', controller.admin.article.create);
  router.post('/admin/article', controller.admin.article.save);
  router.post('/admin/article/:id', controller.admin.article.update);

  // 分类管理
  router.get('/admin/category/delete/:id', controller.admin.category.delete);
  router.get('/admin/category/edit/:id', controller.admin.category.edit);
  router.get('/admin/category', controller.admin.category.index);
  router.get('/admin/category/create', controller.admin.category.create);
  router.post('/admin/category', controller.admin.category.save);
  router.post('/admin/category/:id', controller.admin.category.update);


  router.post('/admin/upload', controller.admin.common.upload);
  router.post('/admin/wupload', controller.admin.common.wupload);

  // 成绩单
  router.get('/admin/exam/delete/:id', controller.admin.exam.delete);
  router.get('/admin/exam/edit/:id', controller.admin.exam.edit);
  router.get('/admin/exam/create', controller.admin.exam.create);
  router.post('/admin/exam', controller.admin.exam.save);
  router.get('/admin/exam', controller.admin.exam.index);
  router.post('/admin/exam/:id', controller.admin.exam.update);

    // 轮播图管理
    router.get('/admin/slide/delete/:id', controller.admin.slide.delete);
    router.get('/admin/slide/edit/:id', controller.admin.slide.edit);
    router.get('/admin/slide', controller.admin.slide.index);
    router.get('/admin/slide/create', controller.admin.slide.create);
    router.post('/admin/slide', controller.admin.slide.save);
    router.post('/admin/slide/:id', controller.admin.slide.update);

  // 礼物
  router.get('/admin/gift/delete/:id', controller.admin.gift.delete);
  router.get('/admin/gift/edit/:id', controller.admin.gift.edit);
  router.get('/admin/gift/create', controller.admin.gift.create);
  router.post('/admin/gift', controller.admin.gift.save);
  router.get('/admin/gift', controller.admin.gift.index);
  router.post('/admin/gift/:id', controller.admin.gift.update);

  // 获取用户openid
  // router.post('/api/getOpenId', controller.api.wechat.getOpenId);
  // 获取微信支付所有参数
  // router.post('/api/getWechatPayParams', controller.api.wechat.getOpenId);
  const xmlparse = app.middleware.xmlparse();
  // 微信支付
  router.post("/api/wechat/pay", controller.api.wechatPay.wxpay);
  // 微信支付回调
  router.post("/api/wechat/notify", xmlparse, controller.api.wechatPay.notify);

  // 直播间
  router.get('/admin/live', controller.admin.live.index);

  router.get('/admin/live/look/:id', controller.admin.live.look);
  router.get('/admin/live/gift/:id', controller.admin.live.gift);
  router.get('/admin/live/comment/:id', controller.admin.live.comment);
  router.get('/admin/live/close/:id', controller.admin.live.close);
  router.get('/admin/live/delete/:id', controller.admin.live.delete);



  // 用户注册
  router.post('/api/reg', controller.api.user.reg);
  // 用户登录
  router.post("/api/login", controller.api.user.login);
  // 退出登录
  router.post('/api/logout', controller.api.user.logout);
  // 获取当前用户信息
  router.get('/api/user/info', controller.api.user.info);
   // 获取当前用户openid
  router.post('/api/user/openid', controller.api.user.openid);
  // 修改用户信息
  router.post('/api/user/edit', controller.api.user.edit);
  // 获取班级信息
  router.get('/api/class/list', controller.api.class.list);
  // 获取科目信息
  router.get('/api/branch/list', controller.api.branch.list);
  // 获取考试项目信息
  router.get('/api/exam/list', controller.api.exam.list);
  // 成绩查询
  router.post('/api/score/search', controller.api.score.search);
  // 成绩详情
router.get('/api/score/detail/:id', controller.api.score.detail);
// 文章列表
router.get('/api/article/list/:id', controller.api.article.list);
// 文章详情
router.get('/api/article/detail/:id', controller.api.article.detail);

// 轮播图列表
router.get('/api/slide/list', controller.api.slide.list);
};
